﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
public partial class MasterPage : System.Web.UI.MasterPage
{
    BookStoreDataContext bs = new BookStoreDataContext();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.IsAuthenticated)
        {
            lblUserName.Text = Session["login"].ToString();
            hplLoginLogout.Text = "Logout";
            hplLoginLogout.NavigateUrl = "logout.spx";
            hplLoginLogout.NavigateUrl = "Logout.aspx";
        }
        else
        {
            hplLoginLogout.Text = "Login";
            hplLoginLogout.NavigateUrl = "CustomLogin.aspx";
            lblUserName.Text = "Guess";
        }
        if (!this.IsPostBack) { 
        getAuthor();
        }
        
    }
    public void getAuthor() {
        var emp = (from item in bs.items
                   select new { item.author }).Distinct();
        //bs.items.Distinct<;
        drpAuthorBook.DataSource = emp;
        drpAuthorBook.DataTextField = "author";
        drpAuthorBook.DataValueField = "author";
        drpAuthorBook.DataBind();
       
            
    }
    protected void btnSearchByAuthorBook_Click(object sender, EventArgs e)
    {

        Session["keyword"] = txtKeyword.Text.Trim();
       
        Response.Redirect("result.aspx");
    }
    protected void drpAuthorBook_SelectedIndexChanged(object sender, EventArgs e)
    {
        Session["author"] = drpAuthorBook.SelectedItem.Text.ToString();
        Response.Redirect("resultauthor.aspx");
    }
    protected void DataList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        Request.QueryString["cateId"] = "3434";
    }
}
